<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var firstNum = 0;
    var sedNum = 0;
    var thNum = 0;
    var lasNum = 0;
    var sum = 0;
    for (var i = 1000; i <= 9999; i++) {
      firstNum = i % 10;
      sedNum = parseInt(i / 10) % 10;
      thNum = parseInt(i / 100) % 10;
      lasNum = parseInt(i / 1000);

      sum = firstNum * firstNum * firstNum * firstNum + sedNum * sedNum * sedNum * sedNum + thNum * thNum * thNum * thNum + lasNum * lasNum * lasNum * lasNum;

      if (i === sum) {
        console.log(i);
      }
    }
    /*
    1634
    8208
    9474
    */

  </script>
</body>

</html>